<!DOCTYPE html>
<html lang="en">

<head>
      <meta charset="UTF-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>Document</title>
</head>

<body>

</body>

</html>
<script>

      //超级管理员

      //项目中异步路由数组
      let asyncRoutes = [
            {
                  name: 'Product',
                  children: [
                        { 'name': 'Trademark' },
                        { 'name': 'Attr' },
                        { 'name': 'Sku' },
                        { 'name': 'Spu' }
                  ]
            },
            {
                  name: 'Acl',
                 
            }
      ];

      //服务器返回的异步路由标记----组件的名字
      let routes = ['Acl', 'Product', 'Sku'];


      //封装函数
      function findAsyncRoute(asyncRoutes, routes) {
           let result  = asyncRoutes.filter(item=>{
                if(routes.includes(item.name)){
                      if(item.children && item.children.length>0){
                         item.children = findAsyncRoute(item.children,routes);
                     }
                      
                     return true;
                }
            })
          return result;
      };


      findAsyncRoute(asyncRoutes,routes);



      //第二次登录:厂长

      console.log(asyncRoutes,22222)

</script>